package com.platform.enums;

import com.platform.comm.constants.EnumOption;
import com.platform.comm.enums.IDictEntry;
import com.platform.comm.enums.IEnumItem;
import com.platform.comm.enums.IEnumOption;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 行政相对人类别
 * @author zhangqian
 */
@EnumOption(name = "xdrType")
public enum XdrType implements IDictEntry, IEnumItem, IEnumOption<String> {
    /**
     * 相对人类别
     */
    NAT("nat", "自然人"),
    LEG_1("leg", "法人及非法人组织"),
    LEG_2("leg2", "个体工商户");

    XdrType(String name, String desc) {
        this.name = name;
        this.desc = desc;
    }

    public final String name;
    public final String desc;

    public String getName() {
        return name;
    }

    public String getDesc() {
        return desc;
    }

    @Override
    public String getKey() {
        return name;
    }

    @Override
    public String getValue() {
        return desc;
    }

    @Override
    public Object getData() {
        return name;
    }

    @Override
    public boolean is(String code) {
        return false;
    }

    @Override
    public String key() {
        return name;
    }

    @Override
    public String value() {
        return desc;
    }

    @Override
    public Map<String, String> enums() {
        return Arrays.stream(values()).collect(Collectors.toMap(IEnumOption::key, IEnumOption::value));
    }

    public static String getNameByDesc(String desc){
        Map<String, String> map = Arrays.stream(values()).collect(Collectors.toMap(IEnumOption::value, IEnumOption::key));
        return map.get(desc);
    }
}
